import request from '@/utils/request'

export default {
  getRoleList(searchModel) {
    return request({
      url: '/role/list',
      method: 'get',
      params: searchModel
    })
  },
  getAllRoleList() {
    return request({
      url: '/role/all',
      method: 'get',
    })
  },
  addRole(role) {
    return request({
      url: '/role',
      method: 'post',
      data: role
    })
  },
  deleteRoleById(id) {
    return request({
      url: `/role/${id}`,
      method: `delete`
    })
  },
  getRoleById(id) {
    return request({
      url: `/role/${id}`,
      method: `get`
    })
  },
  updateRoleById(role) {
    return request({
      url: "/role/",
      method: `put`,
      data: role
    })
  },
  saveRole(role) {
    if(role.roleId == null) {
      return this.addRole(role);
    }else {
      return this.updateRoleById(role);
    }
  },
}
